package com.dones.junit;

import java.util.Date;

import org.hibernate.Session;
import org.hibernate.tutorial.domain.Event;
import org.hibernate.tutorial.util.HibernateUtil;
import org.junit.Test;


public class JunitTest {

	@Test
	public void testHibernate(){
		
		
	        createAndStoreEvent("My Event", new Date());
	        HibernateUtil.getSessionFactory().close();
	        	        
	}
	
	 public void createAndStoreEvent(String title, Date theDate) {
	        Session session = HibernateUtil.getSessionFactory().getCurrentSession();
	        session.beginTransaction();

	        Event theEvent = new Event();
	        theEvent.setTitle(title);
	        theEvent.setDate(theDate);
	        session.save(theEvent);

	        session.getTransaction().commit();
	    }
	
}
